/*!
 * \file __frreport_conver_header.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>
#include "frcomm.h"
#include "frmem.h"

#include "frbyte_buffer.h"
#include "frhex_dump.h"
#include "frlist.h"
#include "frhash2.h"
#include "conntrack.h"
#include "frreport_comm.h"
#include "frct_comm.h"
#include "frreport_convert.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


int __frreport_conver_header(Frreport_type em_type, Frreport_type_l7data em_type_l7data, Frreport_header *p_st_hdr
        , char *p_output, unsigned int ui_out_size);

static void __case1(void)
{
    Frreport_type em_type = FRREPORT_TYPE_STAT_PORT;
    Frreport_type_l7data em_type_l7data =FRREPORT_TYPE_L7DATA_REQ;
    Frreport_header *p_st_hdr = NULL;
    char *p_output = NULL;
    unsigned int ui_out_size = 108;
    int i_ret = 0;

    p_st_hdr = (Frreport_header *)frmalloc(sizeof(Frreport_header));
    memset(p_st_hdr, 0x00, sizeof(Frreport_header));

    p_output = (char *)frmalloc(ui_out_size);
    memset(p_output, 0x00, ui_out_size);

    i_ret = __frreport_conver_header(em_type, em_type_l7data, p_st_hdr, p_output, ui_out_size);
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frfree(p_st_hdr);
    frfree(p_output);
    return;

}

static void __case2(void)
{
    Frreport_type em_type = FRREPORT_TYPE_L7DATA;
    Frreport_type_l7data em_type_l7data =FRREPORT_TYPE_L7DATA_REQ;
    Frreport_header *p_st_hdr = NULL;
    char *p_output = NULL;
    unsigned int ui_out_size = 108;
    int i_ret = 0;

    p_st_hdr = (Frreport_header *)frmalloc(sizeof(Frreport_header));
    memset(p_st_hdr, 0x00, sizeof(Frreport_header));

    p_output = (char *)frmalloc(ui_out_size);
    memset(p_output, 0x00, ui_out_size);

    i_ret = __frreport_conver_header(em_type, em_type_l7data, p_st_hdr, p_output, ui_out_size);
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frfree(p_st_hdr);
    frfree(p_output);
    return;

}

static void __case3(void)
{
    Frreport_type em_type = FRREPORT_TYPE_L7DATA;
    Frreport_type_l7data em_type_l7data =FRREPORT_TYPE_L7DATA_UNKONWN;
    Frreport_header *p_st_hdr = NULL;
    char *p_output = NULL;
    unsigned int ui_out_size = 108;
    int i_ret = 0;

    p_st_hdr = (Frreport_header *)frmalloc(sizeof(Frreport_header));
    memset(p_st_hdr, 0x00, sizeof(Frreport_header));

    p_output = (char *)frmalloc(ui_out_size);
    memset(p_output, 0x00, ui_out_size);

    i_ret = __frreport_conver_header(em_type, em_type_l7data, p_st_hdr, p_output, ui_out_size);
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frfree(p_st_hdr);
    frfree(p_output);
    return;

}

static void __case4(void)
{
    Frreport_type em_type = FRREPORT_TYPE_L7DATA;
    Frreport_type_l7data em_type_l7data =FRREPORT_TYPE_L7DATA_UNKONWN;
    Frreport_header *p_st_hdr = NULL;
    char *p_output = NULL;
    unsigned int ui_out_size = 0;
    int i_ret = 0;

    p_st_hdr = (Frreport_header *)frmalloc(sizeof(Frreport_header));
    memset(p_st_hdr, 0x00, sizeof(Frreport_header));



    i_ret = __frreport_conver_header(em_type, em_type_l7data, p_st_hdr, p_output, ui_out_size);
    CU_ASSERT_EQUAL(i_ret, FR_FAIL);

    frfree(p_st_hdr);
    return;

}

int add_suite___frreport_conver_header(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frtds_convert __frreport_conver_header()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);


    return FR_SUCC;
}
